#pragma once
#include"hashtable.h"

namespace my_uset
{
	template<class K, class Hash = HashFunc<K>>
	class unordered_set
	{
	public:
		struct SefOfT
		{
			const K operator()(const K& key)
			{
				return key;
			}
		};

		typedef typename hash_bucket::HashTable<K, const K, SefOfT,
			Hash>::Iterator iterator;
		typedef typename hash_bucket::HashTable<K, const K, SefOfT,
			Hash>::ConstIterator const_iterator;

		bool insert(const K& k)
		{
			return _ht.Insert(k).second;
		}

		iterator begin()
		{
			return _ht.Begin();
		}

		iterator end()
		{
			return _ht.End();
		}

		const_iterator begin() const
		{
			return _ht.Begin();
		}

		const_iterator end() const
		{
			return _ht.End();
		}

		void test_set1()
		{
			int a[] = { 3,11,86,7,88,82,1,881,5,6,7,6 };
			unordered_set<int> s;
			for (auto e : a)
			{
				s.insert(e);
			}

			unordered_set<int>::iterator it = s.begin();
			while (it != s.end())
			{
				//*it = 1;
				cout << *it << " ";
				++it;
			}
			cout << endl;

			for (auto e : s)
			{
				cout << e << " ";
			}
			cout << endl;
		}
	private:
		hash_bucket::HashTable<K, const K, SefOfT, Hash> _ht;
	};

}
